﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using BLL;

public partial class Spa_huodong3 :WeiPage
{
    promotionBO mbo = new promotionBO();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["code"] != null)
            {
                try
                {
                    string url = string.Format(@"https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + GetAppid() + "&secret=" + GetSecret() + "&code={0}&grant_type=authorization_code", Request.QueryString["code"].ToString());
                    string token = PostRequest(url);
                    if (token.Contains("7200"))
                    {
                        string[] b = token.Split('\"');
                        Session["FromUserName"] = b[13];
                        Session["ToUserName"] = GetAppid();
                    }
                }
                catch (Exception)
                {

                }
            }
            string type1 = "";
            string type2 = "";
            List<promotion> list = mbo.GetModelList(" 1=1 and status='2'  ORDER BY STATUS,BeginDate ");
            foreach (promotion m in list)
            {
                if (m.PTYPE == "1")
                {
                    type1 = "tequan";
                    type2 = "特惠";
                }
                else if (m.PTYPE == "2")
                {
                    type1 = "zhuanxiang";
                    type2 = "专享";
                }
                else if (m.PTYPE == "4")
                {
                    type1 = "huigu";
                    type2 = "回顾";
                }
                else
                {
                    type1 = "huodong";
                    type2 = "活动";
                }
                ul.InnerHtml += string.Format(@"<li  onclick='qy1({3})'  >
      <div  class='{2}'></div>
       <span><i class='xiala'></i></span>{0}
       {1}

      </li>", GetColorTitle(m.Name, m.STATUS), GetColorTime(DateTime.Parse(m.BeginDate.ToString()).ToString("yyyy-MM-dd") + "到" + DateTime.Parse(m.Enddate.ToString()).ToString("yyyy-MM-dd"), m.STATUS),  type1, m.ID);
            }
        }
    }

    public string GetColorTitle(string title, string status)
    {
        if (status == "1")
        {
            return "<strong style='color:Gray;'>" + title + "</strong>";
        }
        else if (status == "2")
        {
            return "<strong style='color:Gray;'>" + title + " </strong>";
        }
        return "<strong   style='color:Gray;'>" + title + "</strong>";
    }

    public string GetColorTime(string time, string status)
    {
        if (status == "1")
        {
            return "<bdo style='color:Gray;'>" + time + "</bdo>";
        }
        else if (status == "2")
        {
            return "<bdo style='color:Gray;'>" + time + " </bdo>";
        }
        return "<bdo  style='color:Gray;'>" + time + "</bdo>";
    }
}